package top.bluesword.laboratory.service;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;
import org.springframework.transaction.support.TransactionSynchronizationManager;
import top.bluesword.laboratory.listener.TestTransactionSynchronization;
import top.bluesword.laboratory.model.Journey;
import top.bluesword.laboratory.repository.JourneyRepository;

/**
 * @author 李林峰
 */
@Service
@RequiredArgsConstructor
@Transactional(rollbackFor = Throwable.class)
public class JourneyService {

  private final JourneyRepository journeyRepository;

  public void save(Journey journey) {
    TransactionSynchronizationManager.registerSynchronization(new TestTransactionSynchronization());
    journeyRepository.save(journey);
  }

}
